package com.wkh.project.model.enums;

import lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wangkehua
 * 评分类型枚举
 */

@Getter
public enum AppTypeEnum {
    SCORE("得分类",0),
    TEST("测评类",1);


    private String text;
    private Integer value;

    AppTypeEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取枚举
     * @param value
     * @return
     */
    public static AppTypeEnum getEnumByValue(Integer value) {
        if (ObjectUtils.isEmpty(value)){
            return null;
        }
        for (AppTypeEnum reviewStatusEnum : AppTypeEnum.values()) {
            if (reviewStatusEnum.getValue().equals(value)) {
                return reviewStatusEnum;
            }
        }
        return null;
    }

    public static List<Integer> getAllValue() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }
}
